package lc;

public class ExOff46 {

    class Solution {
        public int translateNum(int num) {
            if (num < 10) {
                return 1;
            }
            char[] cs = String.valueOf(num).toCharArray();
            int n = cs.length;
            int[] f = new int[n];
            f[0] = 1;
            int p = parse(cs[0], cs[1]);
            f[1] = p < 26 ? 2 : 1;
            for (int i = 2; i < n; i++) {
                p = parse(cs[i - 1], cs[i]);
                f[i] = f[i - 1];
                if (p < 26) {
                    f[i] += f[i - 2];
                }
            }
            return f[n - 1];
        }

        private int parse(char a, char b) {
            return (a - '0') * 10 + (b - '0');
        }
    }

}